import request from "@/utils/request";

// 查询参数列表
export function listOrgConfig(query) {
  return request({
    url: "/system/orgConfig/list",
    method: "get",
    params: query,
  });
}

// 查询参数详细
export function getOrgConfig(configId) {
  return request({
    url: "/system/orgConfig/" + configId,
    method: "get",
  });
}

// 根据参数键名查询参数值
export function getOrgConfigKey(configKey) {
  return request({
    url: "/system/orgConfig/configKey/" + configKey,
    method: "get",
  });
}

// 通过orgId key获取对应的机构参数
export function selectConfigByCache(orgId, configKey) {
  return request({
    url: "/system/orgConfig/selectConfigByCache/" + orgId + "/" + configKey,
    method: "get",
  });
}

// 新增参数配置
export function addOrgConfig(data) {
  return request({
    url: "/system/orgConfig",
    method: "post",
    data: data,
  });
}

// 修改参数配置
export function updateOrgConfig(data) {
  return request({
    url: "/system/orgConfig",
    method: "put",
    data: data,
  });
}

// 修改参数配置
export function updateOrgConfigByKey(key, value) {
  return request({
    url: "/system/orgConfig/updateByKey",
    method: "put",
    data: {
      configKey: key,
      configValue: value,
    },
  });
}

// 删除参数配置
export function delOrgConfig(configId) {
  return request({
    url: "/system/orgConfig/" + configId,
    method: "delete",
  });
}

// 刷新参数缓存
export function refreshCache(orgId) {
  return request({
    url: "/system/orgConfig/refreshCache/" + orgId,
    method: "delete",
  });
}
